package com.zxx.pattern.prototypePattern.prototype3_X.exce;

/**
 * @author zxx on 2020/12/24
 */
public class TestUser {

    public static void main(String[] args) {
        LoginImpl login = new LoginImpl();
        login.login();
        User users = LoginSession.getInstance().getUser();
        System.out.println(users.toString());

        //外部修改User
        users.address = new Address("哈哈", "西湖", "古荡");
        //竟然越过set方法进行修改了，所以要添加浅拷贝
        System.out.println(users.toString());
        //添加clone后这里不会改变了
        System.out.println(LoginSession.getInstance().getUser().toString());

        //只有通过set才能修改信息
        LoginSession.getInstance().setLoginUser(users);
        System.out.println(LoginSession.getInstance().getUser().toString());

    }

}
